---
title: "Reventazón basin: drought monitor using time series"
output:
flexdashboard::flex_dashboard:
orientation: rows
social: menu
source_code: embed
vertical_layout: scroll
---
```{r setup, include=FALSE}
#-------------------- Paquetes --------------------
library(flexdashboard)
library(plotly)
library(dplyr)
library(tidyr)
library(sf)
library(leaflet)
library(rgdal)
library(hydroTSM)
library(drought)
library(lfstat)
library(raster)
```
```{r, include=FALSE}
#--------------- Archivos de datos ----------------
timeseries<-read.csv("E:/Hype data/Streamflow_daily_mm.csv")
times<- subset(timeseries, select= c(1, 2, 3, 4, 5, 7, 9, 13, 14, 15, 16, 17, 18, 20, 21, 22, 23, 24, 27, 28, 34, 35, 37, 49, 50, 54, 63, 64, 65, 66, 67, 68, 77, 84, 88, 93, 94, 107, 108, 145, 146, 149, 158, 177, 221, 337, 338, 342, 370, 371, 384, 385, 393, 399, 418, 419, 436, 437, 462, 506, 507, 525, 526, 549, 550, 551 ))
names(times) <- c(1, 2, 3, 4, 5, 7, 9, 13, 14, 15, 16, 17, 18, 20, 21, 22, 23, 24, 27, 28, 34, 35, 37, 49, 50, 54, 63, 64, 65, 66, 67, 68, 77, 84, 88, 93, 94, 107, 108, 145, 146, 149, 158, 177, 221, 337, 338, 342, 370, 371, 384, 385, 393, 399, 418, 419, 436, 437, 462, 506, 507, 525, 526, 549, 550, 551 )
times<- read.zoo(timeseries, header = TRUE)
```
Upstream
=======================================================================
Row {data-height=1500}
-------------------------------------
### Upstream treshold from Reventazón basin (Threshold Level Method)
```{r}
drought <- find_droughts(times[,1], threshold = "Q80")
plot(drought)
```
Upstream 5m
=======================================================================
Row {data-height=1500}
-------------------------------------
### Upstream treshold from Reventazón basin (Threshold Level Method 5 days)
```{r}
days5 <- pool_it(drought, tmin= 5)
plot(days5)
```
Donwstream
=======================================================================
Row {data-height=1500}
-------------------------------------
### Downstream treshold from Reventazón basin (Threshold Level Method)
```{r}
drought1 <- find_droughts(times[,418], threshold = "Q80")
plot(drought)
```
Donwstream 5m
=======================================================================
Row {data-height=1500}
-------------------------------------
### Downstream treshold from Reventazón basin (Threshold Level Method 5 days)
```{r}
days5 <- pool_it(drought, tmin= 5)
plot(days5)
```